$('.img').click(function() {
	$('.bei').show();
});
$('.fanhui').on('click', function() {
	$('.bei').hide();
});

var num = ['', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
var mul = ['', '十', '百'];

var seat = document.querySelector('.seat');
var section = document.getElementsByClassName('section');
var add = document.querySelector('.add');

add.addEventListener('click', function(e) {;
	var tem = section[0].cloneNode(true);
	var numb;
	if(section.length < 10) {
		tem.querySelector('p').innerHTML = '第' + num[section.length] + '席';
	} else if(section.length < 20) {
		numb = section.length % 10;
		tem.querySelector('p').innerHTML = '第' + '十' + num[numb] + '席';
	} else if(section.length < 100) {
		numb = section.length % 10;
		tem.querySelector('p').innerHTML = '第' + num[parseInt(section.length.toString()[0])] + '十' + num[numb] + '席';
	}
	seat.insertBefore(tem, section[section.length - 1]);
	big();
	one();
})

var content = document.getElementsByClassName('content');

function big() {
	for(var i = 0; i < content.length - 1; i++) {
		content[i].index = i;
		content[i].addEventListener('click', function() {
			for(var j = 0; j < content.length; j++) {
				content[j].parentNode.style.display = 'none';
			}
			this.parentNode.style.width = '100%';
			this.parentNode.style.height = '100%';
			this.parentNode.style.display = 'block';
			this.style.zIndex = '4';
			$('.nv').css('display', 'none');
			$('.img').css('display', 'none');
			$('.bg').css('z-index', '3')
			if(this.index == 0) {
				this.style.transform = 'scale(2) translateY(135px)';
			} else {
				this.style.transform = 'scale(2.7) translateY(100px)';
			}
		});

	}
}
big();

var bg = document.getElementsByClassName('bg')[0];
bg.addEventListener('click', function() {
	for(var i = 0; i < content.length - 1; i++) {
		content[i].index = i;
		for(var j = 0; j < content.length; j++) {
			content[j].parentNode.style.display = 'block';
		}
		if(i == 0) {
			content[i].parentNode.style.width = '50%';
			content[i].parentNode.style.height = 'auto';
			content[i].parentNode.style.margin = '0 auto';
		} else {
			content[i].parentNode.style.width = '50%';
			content[i].parentNode.style.height = 'auto';
		}

		content[i].parentNode.style.display = 'block';
		content[i].style.zIndex = 'none';
		$('.nv').css('display', 'block');
		$('.img').css('display', 'block');
		$('.bg').css('z-index', '-9999');
		if(this.index == 0) {
			content[i].style.transform = 'scale(1) translateY(0)';
		} else {
			content[i].style.transform = 'scale(1) translateY(0)';
		}

	}
});

function one() {
	var append = document.getElementsByClassName('append');
	for(var k = 0; k < append.length - 6; k++) {

		append[k].addEventListener('click', function(a) {
			a.stopPropagation();
				if(k<=stores.length){
					
					this.children[0].innerHTML = '<img src='+stores[0].src+'/>';
				}else{
					this.children[0].innerHTML='<img src='+stores[1].src+'/>'
				}
				console.log(stores.length);
			
		});

	}
};
one();

//获取json
var xmlhttp;
if(window.XMLHttpRequest) {
	//				IE7 + , Firefox, Chrome, Opera, Safari 浏览器执行代码
	xmlhttp = new XMLHttpRequest();
} else {
	// IE6, IE5 浏览器执行代码
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//			var stores;
xmlhttp.open('GET', '../js/img.json');
xmlhttp.send();
xmlhttp.addEventListener('readystatechange', function() {
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		stores = JSON.parse(xmlhttp.responseText);
		return stores
	}
});